<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2021/7/29
 * Time: 15:59
 */

namespace app\admin\controller;


use think\Db;
use think\Request;

class About extends Base
{
    /**
     * 功能介绍
     * @return mixed|\think\response\Json
     */
    public function gong(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('about_id', 1)->update(['about_content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('about_id', 1)->find();
        $this->assign('content', $about_content);
        return $this->fetch('about/gong');
    }
    
    /**
     * 法律声明
     * @return mixed|\think\response\Json
     */
    public function fl(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('about_id', 2)->update(['about_content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('about_id', 2)->find();
        $this->assign('content', $about_content);
        return $this->fetch('about/fl');
    }
    
    /**
     * 平台协议
     * @return mixed|\think\response\Json
     */
    public function ptai(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('about_id', 3)->update(['about_content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('about_id', 3)->find();
        $this->assign('content', $about_content);
        return $this->fetch('about/ptai');
    }
    
    /**
     * 隐私政策
     * @return mixed|\think\response\Json
     */
    public function ys(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('about_id', 4)->update(['about_content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('about_id', 4)->find();
        $this->assign('content', $about_content);
        return $this->fetch('about/ys');
    }
}